def problem_24(ini):
    basea = [0,1,2,3,4,5,6,7,8,9]
    result = []
    for i in range(1,11):
        c = ini/jiec(10-i)
        b = ini%jiec(10-i)
        result.append(base[c])
        ff = basea.pop(c)
        print(ff)
        init = b
    return result

import math
import itertools
n = 10 ** 6
permutations_list = list(itertools.permutations([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 10))
print(permutations_list[n - 1])

n = 10 ** 6
n -= 1
l = []
l_all = set(range(10))
for i in range(10):
    n_ = math.factorial(9 - i)
    l_ = list(l_all - set(l))
    l_.sort()
    l.append(l_[n // n_])
    n = n % n_
print(l)
